-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(s3-deployment): apply least privilege to destination bucket policies #35663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(s3-deployment): apply least privilege to destination bucket policies #35663
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
a4fd28a to
f17cf5b
Compare
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
5 similar comments
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
3 similar comments
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @amandladev ,
Thanks for your contribution. I have left a few comments.
| * @param prefix prefix string | ||
| * @returns normalized prefix string | ||
| */ | ||
| normalizePrefix(prefix?: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can make this a private method.
| ? `${this.normalizePrefix(props.destinationKeyPrefix)}*` | ||
| : '*'; | ||
|
|
||
| this.destinationBucket.grantReadWrite(handler, objectPattern); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default prune is true, which means when we remove source files from the CDK app, the lambda tries to clean up the corresponding files in S3. But it fails because it doesn't have delete permissions for paths that are no longer in the app.
I tested this by:
- deploying a cdk app with stuff in
app/frontendandapp/backend - removing
app/backendsource and deploying it again - second deployment fails because lambda can't delete the old backend files
We should give the lambda delete permissions for the whole bucket (*) to make deletion work properly.
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
1 similar comment
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
Introduction
This change improves security by scoping IAM policies to the specific
destination key prefix instead of granting access to all bucket objects.
Changes:
/<destinationKeyPrefix>/*instead of/*destinationKeyPrefixis specified (e.g., 'deploy/here/', 'efs/'),the Lambda execution role only receives permissions for that specific prefix
/*accessSecurity Benefits:
Affected Use Cases:
✅ Deployment with prefix:
destinationKeyPrefix: 'deploy/here/'✅ EFS-backed deployment:
destinationKeyPrefix: 'efs/', useEfs: true✅ Multiple deployments to same bucket with different prefixes
✅ Deployments without prefix (unchanged behavior)
Testing:
Fixes #35610